<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
</head>
<body>

    <table id="demo" lay-filter="test" ></table>

    <script src="../layui/layui.js"></script>
    <script>
        layui.use('table', function(){
            var table = layui.table
            ,form = layui.form;
            
            //表格初始化
            table.render({
                elem: '#demo'
                ,height: 400
                ,url: './public/select_limit.php?table=t_category' //数据接口
                ,page: true //开启分页
                ,cols: [[ //表头
                {field: 'cid', title: 'ID', width:80, sort: true, fixed: 'left'}
                ,{field: 'cname', title: '分类名称', width:160}
                ,{field: 'pid', title: '父类id', width:120, sort: true}
                
                ]]
                ,done: function(res, curr, count){ 
                    //console.log(res);   // 后台返回来的数据
                }
            });
        })
    </script>
</body>
</html>